;Understand, Correct, Improve           ___
;________/| _________________/\__/\____/  /_____
;\  ____/ |/   __/  /  / __ /  \/  \  \  /   __/
;|   __/  /\__   \    /  __ \      /     \  _/ \
;|___\ \__\____  //__/\_____/\    /__/\  /_____/
;+-------------\/breeze'03----\  /crew-\/------+
;                              \/
; Fishb0ne borntro 2008 [Pentagon 1024SL 2.2]
; Copyright (C) 2008 Fishbone CREW All right reserved
; Written by breeze \ fishbone crew | http://twilight.org.ru
; breeze@tut.by
; 29.01.2008

                        ;IiGRBgrb
_magenta_d	equ	%00011011

		org	#8000

		ld	sp,#5fff

		; clean screen

		ld	hl,#4000
		ld	de,#4001
		ld	bc,#1aff
		ld	(hl),l
		ldir
		xor	a
		out	(254),a

		; show warning
		call	screen

		ei
start_loop	halt
		ld	bc,#7ffe
		in	a,(c)
		bit	0,a
		jr	z,start_mus     ; check 'SPACE'

		ld	bc,#bffe	
		in	a,(c)
		bit	0,a
		jr	z,start_none    ; check 'ENTER'
		jr	start_loop

start_none	ld	a,#c9
		ld	(#c000),a
		ld	(#c003),a
		ld	(#c006),a

start_mus	ld	a,3
		out	(254),a

		ld	a,#11
		call	switchBank

		; put sprite to bank #11

		ld	hl,coolGirl2
		ld	de,#c000
		ld	bc,coolGirl2e-coolGirl2
		ldir

		ld	a,#14
		call	switchBank

		; fill screen color magenta

		ld	a,_magenta_d

		ld	hl,#c000
		ld	de,#c001
		ld	bc,#17ff
		ld	(hl),a
		ldir

		ld	hl,#4000
		ld	de,#4001
		ld	bc,#17ff
		ld	(hl),a
		ldir

		ld	hl,#e000
		ld	de,#e001
		ld	bc,#17ff
		ld	(hl),a
		ldir

		ld	hl,#6000
		ld	de,#6001
		ld	bc,#17ff
		ld	(hl),a
		ldir

		ld	bc,#eff7
		ld	a,%00010001
		out	(c),a	
		
		; show sprite "FISHBONE"

		ld	hl,sprite
		ld	bc,#0e70	; #yyxx, xx - /8
		call	showSpr

		; show sprite "GIRL"

		ld	hl,coolGirl
		ld	bc,#0100	; #yyxx, xx - /8
		call	showSpr

		ld	a,#11
		call	switchBank

		ld	hl,#c000
		ld	de,coolGirl
		ld	bc,coolGirl2e-coolGirl2
		ldir

		ld	a,#14
		call	switchBank

		ld	hl,coolGirl
		ld	bc,#6000	; #yyxx, xx - /8
		call	showSpr

		ei

		ld	a,#10
		call	switchBank

		; Initiolize Music

		ld 	hl,tsfmMusic
		call 	plInit			; init player

		ld	a,#14
		call	switchBank

		; Generate interupt vector

		call	imOn

		; Get Text (main loop)

again		ld	hl,Text_01
nextLetter	ld	a,(hl)
		inc	hl
		cp	32
		jr	z,nextPos	; skip "space" code
		dec	hl
		cp	#00             ; if code #00 - end of text & loop again
		jr	nz,nextStep
		ld	bc,#4078	; reset coords
		ld	(coordsX),bc
		jr	again

nextStep	cp	#01		; if code #01 - end of page , pause & cont
		jr	nz,nextStep2

nst		ld	a,50		; pause 50 halt's
nst1		dec	a
		ld	(nst+1),a
		cp	0
		jr	nz,nst2
		ld	a,50
		ld	(nst+1),a
		push	hl
		call	clearLine	; effect clear lines (for new text)
		pop	hl
		ld	bc,#4078
		ld	(coordsX),bc
		inc	hl
		ld	a,(hl)
		cp	#00
		jr	z,again
		jr	nextStep2

nst2		halt
		jr	nst1

nextStep2	inc	hl
nextStep3	push	hl

		sub	32			; skip 32 bytes of ASCII code
		ld	hl,58			; 58 byte one sprite size
		call	_mul16x8
		ld	bc,letters
		add	hl,bc
		
mainLoop	halt
		push	hl
		ld	bc,(coordsX)		;#4078	; #yyxx, xx - /8
		call	sibolNinjaUp		; show simbol
		pop	hl
		cp	#ff
		jr	nz,mainLoop
		pop	hl			; simbol showed

nextPos		ld	a,(coordsX)
		add	a,8
		cp	248			; check X for end of screen
		jr	nz,nOk
		ld	a,(coordsY)
		add	a,16
		ld	(coordsY),a		; new Y
		ld	a,#78
nOk		ld	(coordsX),a
		jr	nextLetter

switchBank	ld	bc,#7ffd		; memory switcher
		out	(c),a
		ret

imOn		halt				; main interupt enabler
		di
		ld 	hl,#be00
		ld 	bc,#0100
		ld 	d,h
		ld 	e,b
		ld 	(hl),#7e		; vector in #7e7e
		ld 	a,h
		ldir  
		ld 	i,a
		im 	2
		ld	hl,#7e7e		; put in addres #7e7e
		ld	a,195			; jp interupt
		ld	(hl),a
		inc	hl
		ld	bc,interupt
		ld	(hl),bc
		ei
		ret

imOff		halt				; stop interupt (not used here)
		di
		ld	a,61
		ld	i,a
		im	1
		ei
		ret

interupt	push	hl,bc,de,af		; main interupt circle

		ld	a,#10
		call	switchBank
		
		call 	plPlay			; play next note
		
		ld	a,#14
		call	switchBank

		pop	af,de,bc,hl
		ei
		ret

; Old effect clear screen

clearLine	ld	a,112/2			; 112 line need to be clean
clLoop		halt
		push	af
clFirst		ld 	bc,#4078		; yyxx
		ld 	de,16			; len
		;          IiGRBgrb
		ld	a,%00011011		; color
                call	drawHline8x
clSecond	ld 	bc,#B178		; yyxx
		ld 	de,16			; len
		;          IiGRBgrb
		ld	a,%00011011		; color
                call	drawHline8x

		ld	a,(clFirst+2)
		inc	a
		inc	a
		ld	(clFirst+2),a

		ld	a,(clSecond+2)
		dec	a
		dec	a
		ld	(clSecond+2),a

		pop	af
		dec	a
		jr	nz,clLoop
		ld	a,#40
		ld	(clFirst+2),a
		ld	a,#B1
		ld	(clSecond+2),a
		ld	a,112/2
		ld	(clearLine+1),a

                ret

;--------------------------------------------------------------
; current possition of simbol
coordsX		db	#78
coordsY		db	#40

; text for intro
                        ;0123456789012345
Text_01		db	"    HI PPLZ!    "
		db	"                "
		db	" FISHBONE  CREW "
		db	"PROUDLY PRESENTS"
		db	"                "
		db	" FIRST 16COLORS "
		db	"  SMALL INTRO!  "
		db	#01			; pause & next

		db	" \"BORNTRO 2008\" "
		db	"                "
		db	"  ESPECIAL FOR  "
		db	" PENTAGON  1024 "
		db	"   SL2.2 WITH   "
		db	" TURBOSOUND  FM "
		db	"   MUSIC CARD   "
		db	#01

		db	"  THIS BORNTRO  "
		db	"  DEDICATED TO  "
		db	" THE GREAT DAY- "
		db	"   26 JANUARY.  "
		db	" FISHBONE  CREW "
		db	"  WAS  FOUNDED  "
		db	"  7 YEARS AGO.  "
		
		db	#01

		db	"       A        "
		db	"     GREAT      "
		db	"   VARIETY OF   "
		db	"SPECCY'N'PEECEE "
		db	"    SOFTWARE    "
		db	"  WAS  CREATED  "
		db	"     BY US.     "

		db	#01

		db	" FISHBONE  CREW "
		db	"     MEMBERS    "
		db	"                "
		db	"SPECCY DEVISION:"
		db	"                "
		db	"     BREEZE     "
		db	"  ORG,GFX,CODE  "
		db	#01

		db	"PEECEE DEVISION:"
		db	"     BREEZE     "
		db	"ORG,GFX,CODE,WEB"
		db	"                "
		db	"  ZORG - MUSIC  "
		db	"                "
		db	" DEEJAN - MUSIC "
		db	#01

		db	"GRETINGS GOES TO"
		db	"                "
		db	"  ZORG, DEEJAN, "
		db	" SINUS, STRIKER,"
		db	" FOX FLUFFY^^S, "
		db	"TOM HIAL, SMONT,"
		db	"BLAZE, BLADE, HA"
		db	#01

		db	"QUASAR, MAST, PP"
		db	"WOOLF, S.SHTURM,"
		db	"FREEMAN, SMOKERS"
		db	"FATAL SNIPE  AND"
		db	" ALL MEMBERS OF "
		db	"  FENOMEN CREW  "
		db	"...AND KOJI9I ;)"
		db	#01

		db	"ZXAAA, VITAMIN, "
		db	" WLODEK  BLACK, "
		db	" CITYACE, CARO, "
		db	"  RISKEJ, CHRV, "
		db	" K.O.E., SONIC, "
		db	"ALCO, NEWART,SMT"
		db	"CONAN, KYV,DIVER"
		db	#01

		db	"ELF/2, SLASH^ATD"
		db	"MIKKA A,SQ,SPIRO"
		db	" COOLER, JERRI, "
		db	"RASMER, SPLINTER"
		db	" EVGENI MUCHKIN "
		db	"SPECTRE, BUDDER,"
		db	"Q-MASTER, VINNY "
		db	#01

		db	"FOLKEN, MAT1SHA,"
		db	"SLIDER, MAKSAGOR"
		db	"UNBELIEVER, DDP,"
		db	"SAM STYLE, PROF,"
		db      "YERZMYEY, LUKASZ"
		db      "VELESOFT, ICABOD"
		db      "GASMAN, RAWW.ORG"
		db	#01

		db	"                "
		db	"                "
		db	"     AND ALL    "
		db	"  WHO  KEEPING  "
		db	"  SPECCY SCENE  "
		db	"    ALIVE !!    "
		db	"                "
		db	#01

		db	"THAT'S ALL FOLKS"
		db	"                "
		db	" SMALL CREDITS: "
		db	"                "
		db	"BREEZE..CODE,GFX"
		db	"                "
		db	"RISKEJ.....MUSIC"
		db	#01

		db	"                "
		db	"                "
		db	"                "
		db	"AND REMEMBER ..."
		db	"                "
		db	"                "
		db	"                "
		db	#01

		db	"          ____  "
		db	"         /   /  "
		db	" ___    /   /   "
		db	" \\   \\ /   /    "
		db	"  \\___/___/     "
		db	"  AMIGA RULEZ-  "
		db	"BUT SPECCY 4EVER"
		db	#01

		db	"                "
		db	" FISHBONE  CREW "
		db	"                "
		db	"                "
		db	" BELARUS,GRODNO "
		db	"      2008      "
		db	"                "
		db	#01

		db	"                "
		db	"                "
		db	"                "
		db	"                "
		db	"                "
		db	"                "
		db	"    AND AGAIN..."
		db	#01

		db	#00			; end & loop

;---------------------------------------------------------

		include "showspr.asm"
		include "hLine.asm"

sprite		incbin "fishbone.spr"

letters		include "font.asm"

coolGirl	incbin "f-girl-01.spr"

		org	#6000
coolGirl2	incbin "f-girl-02.spr"
coolGirl2e
theEnd		nop
		
	DISPLAY theEnd

		org	#c000
		include "player.asm"

screen		incbin	"packed.bin"	; "warning" screen at start

realEnd
		DEVICE ZXSPECTRUM128
		;save snapshot file with start of program START
		SAVESNA "snapshot.sna",#8000
		;SAVEBIN "borntro.C",#6000,realEnd-#6000

